package com.itheima.dubbo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.db.UserInfo;
import com.sun.deploy.util.BlackList;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 阿鹏
 * @date 2021/1/25 17:32
 */

public interface BlackListMapper extends BaseMapper<BlackList> {

    @Select("select ui.* from tb_black_list bl left join tb_user_info ui on bl.black_user_id=ui.id" +
            " where bl.user_id = #{userId}")
    IPage<UserInfo> findBlackList(Page<UserInfo> page, @Param("userId") Long userId);

    @Insert("insert into tb_black_list values(null, #{userId}, #{blackUserId}," +
            "null, null)")
    void addBlackList(@Param("userId") Long userId,@Param("blackUserId") Long likeUserId);

    @Select("select count(*) from tb_black_list where user_id = #{userId} " +
            "and black_user_id = #{blackUserId}")
    Long selectExists(@Param("userId") Long userId,@Param("blackUserId") Long showUserId);
}
